const express = require('express')
const cors = require('cors')
const fs = require('fs')
const app = express()

app.use(cors({
    credentials: true,
    optuibsSyccessStatys:200,
    origin:'http://127.0.0.1:5500'
}))

app.get('/user',(request,response)=>{
    const user = {name:'YC',age:22}
    fs.readFile('2.jpg',(err,data) =>{
        if(err){
            response.sendStatus(500)
        }else{
            user.avatar = data.toString('base64')
            response.send(user)
        }
        
    })
})

app.listen(3000,function() {
    console.log('server started at http://127.0.0.1:3000');
})
